package com.cheems.henau_doc_ai.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cheems.henau_doc_ai.common.BaseResponse;
import com.cheems.henau_doc_ai.common.ErrorCode;
import com.cheems.henau_doc_ai.common.ResultUtils;
import com.cheems.henau_doc_ai.domain.User;
import com.cheems.henau_doc_ai.domain.dto.UserDTO;
import com.cheems.henau_doc_ai.exception.BusinessException;
import com.cheems.henau_doc_ai.exception.ThrowUtils;
import com.cheems.henau_doc_ai.mapper.UserMapper;
import com.cheems.henau_doc_ai.service.UserService;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.math.BigInteger;

@ResponseBody
@RestController
public class UserController {

    @Resource
    private UserService userService;

    @Resource
    private UserMapper userMapper;

    @PostMapping("/login")
    public BaseResponse<User> login(@RequestBody UserDTO userDTO) {
        String code = userDTO.getCode();
        User user = userService.login(code);
        return ResultUtils.success(user);
    }

    //测试接口
    @GetMapping("/getUser")
    public BaseResponse<User> getUser() {
        User user = userService.getById(1);
        if (user == null) {
            throw new BusinessException(ErrorCode.NOT_FOUND_ERROR);
        }
        return ResultUtils.success(user);
    }
}
